﻿using Bot.Domain;
using Google.Cloud.Dialogflow.V2;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bot.Domain.DialogFlow.Convertor
{
    public class EntityConvertor: IEntityConvertor
    {
        public void Convert( EntityType result, EntityDto entitydto)
        {
            //result.EntityTypeName = null;
            result.Kind = EntityType.Types.Kind.Map;
            result.AutoExpansionMode = EntityType.Types.AutoExpansionMode.Unspecified;
            result.DisplayName = entitydto.EntityName;
            if (entitydto.ListEntityItems != null && entitydto.ListEntityItems.Count > 0)
            {
                foreach (ListEntityItemDto item in entitydto.ListEntityItems)
                {

                    EntityType.Types.Entity temp = new EntityType.Types.Entity();
                    temp.Value = item.KeyWord;
                    string[] list = item.SynonymsOfKeyWord.Split(',');
                    foreach (string sr in list)
                    {
                        temp.Synonyms.Add(sr);
                    }

                    result.Entities.Add(temp);
                }
            }
        }
    }
}
